﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace CrashSimul8or
{
    public class CircularParticle : Particle
    {
        public float radius;
        public float circularVelocity;
        public float angleInCircle;

        public CircularParticle(Texture2D texture, Vector2 circleCenter, float circularVelocity, float angleInCircle,
                                float radius, Color color, float size, int ttl)
            : base(texture, circleCenter, Vector2.Zero, 0, 0, color, size, ttl)
        {
            this.circularVelocity = circularVelocity;
            this.radius = radius;
            this.angleInCircle = angleInCircle;
        }

        public override void Update()
        {
            TTL--;
            angleInCircle += circularVelocity;
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            Rectangle sourceRectangle = new Rectangle(0, 0, Texture.Width, Texture.Height);
            Vector2 origin = new Vector2(Texture.Width / 2, Texture.Height / 2);

            spriteBatch.Draw(Texture, Position + new Vector2((float)Math.Cos(angleInCircle) * radius, (float)Math.Sin(angleInCircle) * radius), sourceRectangle, Color,
                Angle, origin, Size, SpriteEffects.None, 0f);
        }
    }
}
